﻿using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Runtime.InteropServices;
using System.Threading;
using System.Web;
using System.Web.Services;
using CommonLibrary;
using CommonLibrary.BLL;
using CommonLibrary.DBUtility;
using CommonLibrary.Model;

namespace WebServiceSmsSeries
{
    /// <summary>
    /// 短信服务器
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [System.ComponentModel.ToolboxItem(false)]
    // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务，请取消对下行的注释。
    // [System.Web.Script.Services.ScriptService]
    public class SmsSeries : System.Web.Services.WebService
    {
        SqlHelper sqlHelper=new SqlHelper(true);
        /// <summary>
        /// 消息列表
        /// </summary>
        static MsgList msgList = new MsgList();

        /// <summary>
        /// 发送短消息
        /// </summary>
        /// <param name="UserID">用户ID</param>
        /// <param name="DestNumber">目标号码(可用逗号(,)分隔) </param>
        /// <param name="Content">短消息内容（不超过70个汉字）</param>
        /// <param name="SignName">短信签名</param>
        /// <param name="SendPriority">优先级</param>
        /// <param name="ValidMinute">有效期</param>
        [WebMethod]
        public void SendMsg(string UserID, string DestNumber,
            string Content, string SignName, int SendPriority, int ValidMinute)
        {
            int splitCount = Content.Length / 70+1;

            SendTaskInfo sendTaskInfo = new SendTaskInfo(UserID.ToString(), DestNumber, Content,
                                                     SignName, SendPriority, DateTime.Now, ValidMinute,
                                                     0, -1, splitCount);
            SendTask.Insert(sendTaskInfo);


            //            char[] spliter = { ',','，' };
            //string[] strings = DestNumber.Split(spliter);
            //foreach (string s in strings)
            //{     }
            

            //Msg msg=new Msg();
            //msg.UserID = UserID;
            //msg.MobileNo = DestNumber;
            //msg.MsmMsg = Msg;
            //msgList.Add(msg);
        }

        /// <summary>
        /// 查询消息列表
        /// </summary>
         //[WebMethod]
        //public MsgList SearchMsgList()
        // {
        //    MsgList _msgList=new MsgList();

        //    int count = msgList.Count;

        //    if (count > 100)
        //    {
        //        count = 100;
        //    }

        //    for (int i = 0; i < count; i++)
        //    {
        //        _msgList.Add(msgList[i]);
        //    }

        //    for (int i = 0; i < count; i++)
        //    {
        //        msgList.RemoveAt(0);
        //    }
        //    //msgList.Clear();

        //    return _msgList;
        // }
    }
}
